<html>
<head><meta charset="utf-8"><title>naked + in(reg) · project-inline-asm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/index.html">project-inline-asm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html">naked + in(reg)</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="228232833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/naked%20%2B%20in%28reg%29/near/228232833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> joey <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html#228232833">(Mar 01 2021 at 13:53)</a>:</h4>
<p>Can I use: in("x1") &amp;some_addr, in a #[naked] function?</p>



<a name="228234982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/naked%20%2B%20in%28reg%29/near/228234982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html#228234982">(Mar 01 2021 at 14:06)</a>:</h4>
<p>That would force the compiler to generate code to put the some_addr into a register, wouldn't it?</p>



<a name="228235118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/naked%20%2B%20in%28reg%29/near/228235118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> joey <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html#228235118">(Mar 01 2021 at 14:07)</a>:</h4>
<p>yes, and then I guess it wouldnt be allowed, if a naked fn's body has to only contain what the asm() contains</p>



<a name="228235365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/naked%20%2B%20in%28reg%29/near/228235365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html#228235365">(Mar 01 2021 at 14:09)</a>:</h4>
<p>Right. That said <code>naked</code> is pretty bad at enforcing that condition.</p>



<a name="228235469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/naked%20%2B%20in%28reg%29/near/228235469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html#228235469">(Mar 01 2021 at 14:09)</a>:</h4>
<p>(by pretty bad I mean it doesn't do that at all and many different things can tickle LLVM just enough to have it to fail uphold that requirement)</p>



<a name="228235778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/naked%20%2B%20in%28reg%29/near/228235778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> joey <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html#228235778">(Mar 01 2021 at 14:11)</a>:</h4>
<p>you're making me nervous at converting my external assembly files to naked functions :P</p>



<a name="228236302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/naked%20%2B%20in%28reg%29/near/228236302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html#228236302">(Mar 01 2021 at 14:14)</a>:</h4>
<p>I would recommend <code>global_asm!</code> if its an option.</p>



<a name="228237413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/naked%20%2B%20in%28reg%29/near/228237413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> joey <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html#228237413">(Mar 01 2021 at 14:20)</a>:</h4>
<p>that's what Im currently doing</p>



<a name="228237608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/naked%20%2B%20in%28reg%29/near/228237608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> joey <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html#228237608">(Mar 01 2021 at 14:21)</a>:</h4>
<p>but I want support for stuff like <a href="https://github.com/rust-lang/rust/issues/81838#issuecomment-774538298">https://github.com/rust-lang/rust/issues/81838#issuecomment-774538298</a></p>



<a name="228237719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/naked%20%2B%20in%28reg%29/near/228237719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> joey <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html#228237719">(Mar 01 2021 at 14:22)</a>:</h4>
<p>so for now I have to duplicate constants or add some complex <a href="http://build.rs">build.rs</a> or used naked+asm!()</p>



<a name="228265451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/naked%20%2B%20in%28reg%29/near/228265451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html#228265451">(Mar 01 2021 at 16:57)</a>:</h4>
<p><code>naked</code> restrictions are actually enforced now.</p>



<a name="228265769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/naked%20%2B%20in%28reg%29/near/228265769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html#228265769">(Mar 01 2021 at 16:58)</a>:</h4>
<p>You can use <code>const</code>/<code>sym</code> in naked functions, but not <code>in</code>/<code>out</code>.</p>



<a name="228265874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/naked%20%2B%20in%28reg%29/near/228265874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/naked.20.2B.20in(reg).html#228265874">(Mar 01 2021 at 16:58)</a>:</h4>
<p>You're supposed to get argument directly from their corresponding location in the function ABI.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>